package com.mofang.activity.notice;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.mofang.R;
import com.mofang.activity.BaseTitleViewActiviey;
import com.mofang.adapters.MoFangNewsAdapter;

public class MoFangNewsActivity extends BaseTitleViewActiviey implements
		OnClickListener {

	private LinearLayout newsClassification_ly1;
	private LinearLayout newsClassification_ly2;
	private LinearLayout newsClassification_ly3;
	private LinearLayout newsClassification_ly4;

	private TextView newsClassification_text1;
	private TextView newsClassification_text2;
	private TextView newsClassification_text3;
	private TextView newsClassification_text4;

	private ImageView newsClassification_iv1;
	private ImageView newsClassification_iv2;
	private ImageView newsClassification_iv3;
	private ImageView newsClassification_iv4;

	private MoFangNewsAdapter adapter;
	private ListView mo_fang_news_list;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_mo_fang_news);
		setNavigationTitle("魔方快报");
		setNavigationLeftBtnImage(R.drawable.return_arrow);
		findView();
	}

	private void findView() {
		// TODO Auto-generated method stub

		newsClassification_ly1 = (LinearLayout) findViewById(R.id.mo_fang_newsClassification_ly1);
		newsClassification_ly1.setOnClickListener(this);
		newsClassification_ly2 = (LinearLayout) findViewById(R.id.mo_fang_newsClassification_ly2);
		newsClassification_ly2.setOnClickListener(this);
		newsClassification_ly3 = (LinearLayout) findViewById(R.id.mo_fang_newsClassification_ly3);
		newsClassification_ly3.setOnClickListener(this);
		newsClassification_ly4 = (LinearLayout) findViewById(R.id.mo_fang_newsClassification_ly4);
		newsClassification_ly4.setOnClickListener(this);

		newsClassification_text1 = (TextView) findViewById(R.id.mo_fang_newsClassification_text1);
		newsClassification_text2 = (TextView) findViewById(R.id.mo_fang_newsClassification_text2);
		newsClassification_text3 = (TextView) findViewById(R.id.mo_fang_newsClassification_text3);
		newsClassification_text4 = (TextView) findViewById(R.id.mo_fang_newsClassification_text4);

		newsClassification_iv1 = (ImageView) findViewById(R.id.mo_fang_newsClassification_iv1);
		newsClassification_iv2 = (ImageView) findViewById(R.id.mo_fang_newsClassification_iv2);
		newsClassification_iv3 = (ImageView) findViewById(R.id.mo_fang_newsClassification_iv3);
		newsClassification_iv4 = (ImageView) findViewById(R.id.mo_fang_newsClassification_iv4);

		adapter = new MoFangNewsAdapter(getApplicationContext());
		mo_fang_news_list = (ListView) findViewById(R.id.mo_fang_news_list);
		mo_fang_news_list.setAdapter(adapter);
		// ListHeightUtils.setListViewHeightBasedOnChildren(poly_effective_list);
		mo_fang_news_list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				Intent intent = new Intent(getApplicationContext(),
						NewContentActivity.class);
				startActivity(intent);

			}
		});
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		Intent intent;

		switch (v.getId()) {
		case R.id.mo_fang_newsClassification_ly1:
			// 改变字体和线的颜色为默认颜色
			newsClassification_text2.setTextColor(this.getResources().getColor(
					R.color.textColor2));
			newsClassification_iv2.setBackgroundColor(this.getResources()
					.getColor(R.color.gray_bg));
			// 改变字体和线的颜色为默认颜色
			newsClassification_text3.setTextColor(this.getResources().getColor(
					R.color.textColor2));
			newsClassification_iv3.setBackgroundColor(this.getResources()
					.getColor(R.color.gray_bg));
			// 改变字体和线的颜色为默认颜色
			newsClassification_text4.setTextColor(this.getResources().getColor(
					R.color.textColor2));
			newsClassification_iv4.setBackgroundColor(this.getResources()
					.getColor(R.color.gray_bg));
			// 改变字体和线的颜色为选中颜色
			newsClassification_text1.setTextColor(this.getResources().getColor(
					R.color.black_green));
			newsClassification_iv1.setBackgroundColor(this.getResources()
					.getColor(R.color.black_green));

			break;
		case R.id.mo_fang_newsClassification_ly2:
			// 改变字体和线的颜色为默认颜色
			newsClassification_text1.setTextColor(this.getResources().getColor(
					R.color.textColor2));
			newsClassification_iv1.setBackgroundColor(this.getResources()
					.getColor(R.color.gray_bg));
			// 改变字体和线的颜色为默认颜色
			newsClassification_text3.setTextColor(this.getResources().getColor(
					R.color.textColor2));
			newsClassification_iv3.setBackgroundColor(this.getResources()
					.getColor(R.color.gray_bg));
			// 改变字体和线的颜色为默认颜色
			newsClassification_text4.setTextColor(this.getResources().getColor(
					R.color.textColor2));
			newsClassification_iv4.setBackgroundColor(this.getResources()
					.getColor(R.color.gray_bg));
			// 改变字体和线的颜色为选中颜色
			newsClassification_text2.setTextColor(this.getResources().getColor(
					R.color.black_green));
			newsClassification_iv2.setBackgroundColor(this.getResources()
					.getColor(R.color.black_green));

			break;
		case R.id.mo_fang_newsClassification_ly3:
			// 改变字体和线的颜色为默认颜色
			newsClassification_text1.setTextColor(this.getResources().getColor(
					R.color.textColor2));
			newsClassification_iv1.setBackgroundColor(this.getResources()
					.getColor(R.color.gray_bg));
			// 改变字体和线的颜色为默认颜色
			newsClassification_text2.setTextColor(this.getResources().getColor(
					R.color.textColor2));
			newsClassification_iv2.setBackgroundColor(this.getResources()
					.getColor(R.color.gray_bg));
			// 改变字体和线的颜色为默认颜色
			newsClassification_text4.setTextColor(this.getResources().getColor(
					R.color.textColor2));
			newsClassification_iv4.setBackgroundColor(this.getResources()
					.getColor(R.color.gray_bg));
			// 改变字体和线的颜色为选中颜色
			newsClassification_text3.setTextColor(this.getResources().getColor(
					R.color.black_green));
			newsClassification_iv3.setBackgroundColor(this.getResources()
					.getColor(R.color.black_green));

			break;
		case R.id.mo_fang_newsClassification_ly4:
			// 改变字体和线的颜色为默认颜色
			newsClassification_text1.setTextColor(this.getResources().getColor(
					R.color.textColor2));
			newsClassification_iv1.setBackgroundColor(this.getResources()
					.getColor(R.color.gray_bg));
			// 改变字体和线的颜色为默认颜色
			newsClassification_text2.setTextColor(this.getResources().getColor(
					R.color.textColor2));
			newsClassification_iv2.setBackgroundColor(this.getResources()
					.getColor(R.color.gray_bg));
			// 改变字体和线的颜色为默认颜色
			newsClassification_text3.setTextColor(this.getResources().getColor(
					R.color.textColor2));
			newsClassification_iv3.setBackgroundColor(this.getResources()
					.getColor(R.color.gray_bg));
			// 改变字体和线的颜色为选中颜色
			newsClassification_text4.setTextColor(this.getResources().getColor(
					R.color.black_green));
			newsClassification_iv4.setBackgroundColor(this.getResources()
					.getColor(R.color.black_green));

			break;
		}
	}
}
